<?php

require __DIR__ . '/../vendor/autoload.php';

use Queue\ProcessInvoker\{
    WindowsProcessInvoker,
    UnixProcessInvoker,
};
use Queue\Task\{
    EchoTask,
    Sha1ChecksumTask,
};
use Queue\Manager\AsyncQueueManager;
use Queue\Interfaces\TaskInterface;

if (\strtoupper(\substr(\PHP_OS, 0, 3)) === 'WIN') {
    // This is Windows server
    $processInvoker = new WindowsProcessInvoker();
} else {
    $processInvoker = new UnixProcessInvoker();
}

$asyncQueueManager = new AsyncQueueManager($processInvoker);

$firstTask = new EchoTask("test text");
$asyncQueueManager->enqueue($firstTask);
$asyncQueueManager->run();
$secondTask = new Sha1ChecksumTask(__DIR__ . '/file_for_checksum.txt', '7F4F1D32A2FF69E27365A10AE52B617B8F0BB406');
$asyncQueueManager->enqueue($secondTask);

echo \json_encode($asyncQueueManager->getTaskStatuses());
